#include "mainwindow.h"
#include "theme_manager.h"
#include "scale_manager.h"
#include "combo_checker.h"
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QTabWidget>
#include <QListWidget>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QPushButton>
#include <QCheckBox>
#include <QSlider>
#include <QLabel>
#include <QFileDialog>
#include <QMessageBox>
#include <QRandomGenerator>
#include <QSoundEffect>
#include <QAudioDeviceInfo>
#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent),
      m_currentScene(1),
      m_showingCombo(false),
      m_currentComboPath(QString()),
      rightWidget(nullptr),
      m_view(nullptr),
      m_scene(nullptr),
      m_upcloList(nullptr),
      m_downcloList(nullptr),
      m_shoesList(nullptr),
      m_dressList(nullptr),
      m_scene1Btn(nullptr),
      m_scene2Btn(nullptr),
      m_saveBtn(nullptr),
      m_resetBtn(nullptr),
      m_randomBtn(nullptr),
      m_confirmBtn(nullptr),
      m_themeCheckBox(nullptr),
      m_bgmToggleBtn(nullptr),
      m_volumeSlider(nullptr),
      m_volumeLabel(nullptr),
      m_audioManager(new AudioManager(this)),
      m_themeManager(new ThemeManager(this)),
      m_scaleManager(new ScaleManager(this)),
      m_comboChecker(new ComboChecker(this)),
      m_clothesList(QList<ClothesInfo>()),
      m_sceneItem(nullptr),
      m_upcloItem(nullptr),
      m_downcloItem(nullptr),
      m_dressItem(nullptr),
      m_shoesItem(nullptr),
      m_characterItem(nullptr),
      m_characterPath(QString()),
      m_outfitCombos(QList<OutfitCombo>()),
      m_comboItem(nullptr),
      m_loadingLabel(nullptr),
      m_clothesScale(0.22),
      m_characterScale(0.35)
{

    m_characterPath = ResourceManager::getDefaultCharacterPath();
    m_clothesList = ResourceManager::loadClothes();
    m_outfitCombos = ResourceManager::loadOutfitCombos();

    initUI();
    initConnections();
    loadCharacter();
    loadClothes();
    initBGM();
    checkAudioDevices();

    // 初始化状态设置
    if (m_bgmToggleBtn) m_bgmToggleBtn->setText("开启BGM");
    if (m_volumeSlider) m_volumeSlider->setValue(50);
    onScene1BtnClicked(); // 默认房间场景
}
MainWindow::~MainWindow()
{
    delete m_audioManager;
    delete m_themeManager;
    delete m_scaleManager;
    delete m_comboChecker;
}

// UI 初始化（仅创建控件和布局）
void MainWindow::initUI()
{
    setWindowTitle("服饰搭配工具");
        setMinimumSize(1000, 700);

        m_loadingLabel = new QLabel("就绪");
        m_loadingLabel->setStyleSheet("color: black; background: transparent; font-size: 10px;");

        QWidget *centralWidget = new QWidget(this);
        QHBoxLayout *mainLayout = new QHBoxLayout(centralWidget);
        setCentralWidget(centralWidget);
        centralWidget->setStyleSheet("background-color: rgba(255, 255, 255, 0);");

        // 左侧标签页
        QTabWidget* tabWidget = new QTabWidget;
        tabWidget->setStyleSheet("QTabWidget::pane { border: 0; background-color: rgba(255, 255, 255, 50); } "
                                "QTabWidget::tab-bar { alignment: center; } "
                                "QTabBar::tab { background-color: rgba(255, 255, 255, 100); color: black; } "
                                "QTabBar::tab:selected { background-color: rgba(255, 255, 255, 150); }");

        m_upcloList = new QListWidget;
        m_upcloList->setViewMode(QListWidget::IconMode);
        m_upcloList->setIconSize(QSize(80,80));
        m_upcloList->setResizeMode(QListWidget::Adjust);
        m_upcloList->setSpacing(10);
        m_upcloList->setStyleSheet("background-color: rgba(255, 255, 255, 50); border: 1px solid rgba(255, 255, 255, 100);");
        tabWidget->addTab(m_upcloList,"上衣");

        m_downcloList = new QListWidget;
        m_downcloList->setViewMode(QListWidget::IconMode);
        m_downcloList->setIconSize(QSize(80, 80));
        m_downcloList->setResizeMode(QListWidget::Adjust);
        m_downcloList->setSpacing(10);
        m_downcloList->setStyleSheet("background-color: rgba(255, 255, 255, 50); border: 1px solid rgba(255, 255, 255, 100);");
        tabWidget->addTab(m_downcloList, "下装");

        m_shoesList = new QListWidget;
        m_shoesList->setViewMode(QListWidget::IconMode);
        m_shoesList->setIconSize(QSize(80, 80));
        m_shoesList->setResizeMode(QListWidget::Adjust);
        m_shoesList->setSpacing(10);
        m_shoesList->setStyleSheet("background-color: rgba(255, 255, 255, 50); border: 1px solid rgba(255, 255, 255, 100);");
        tabWidget->addTab(m_shoesList, "鞋子");

        m_dressList = new QListWidget;
        m_dressList->setViewMode(QListWidget::IconMode);
        m_dressList->setIconSize(QSize(80, 80));
        m_dressList->setResizeMode(QListWidget::Adjust);
        m_dressList->setSpacing(10);
        m_dressList->setStyleSheet("background-color: rgba(255, 255, 255, 50); border: 1px solid rgba(255, 255, 255, 100);");
        tabWidget->addTab(m_dressList, "连衣裙");

        mainLayout->addWidget(tabWidget, 1);

        // 中间展示区
        m_view = new QGraphicsView;
        m_scene = new QGraphicsScene;
        m_scene->setSceneRect(0,0,700,700);
        m_view->setScene(m_scene);
        m_view->setMinimumSize(410, 510);
        m_view->setBackgroundBrush(Qt::transparent);
        m_view->setStyleSheet("background: transparent; border: 1px solid rgba(255, 255, 255, 100);");
        m_view->setSceneRect(m_scene->sceneRect());
        m_view->fitInView(m_scene->sceneRect(), Qt::KeepAspectRatio);
        m_view->setResizeAnchor(QGraphicsView::AnchorViewCenter);
        m_view->setDragMode(QGraphicsView::RubberBandDrag);
        m_view->setMouseTracking(true);
        m_view->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
        m_view->setRenderHint(QPainter::Antialiasing);
        mainLayout->addWidget(m_view, 2);

        // 右侧功能区
        rightWidget = new QWidget;
        rightWidget->setObjectName("rightWidget");
        QVBoxLayout *rightLayout = new QVBoxLayout(rightWidget);
        rightLayout->setSpacing(20);
        rightWidget->setStyleSheet("background-color: rgba(255, 255, 255, 50); border: 1px solid rgba(255, 255, 255, 100);");

        m_scene1Btn = new QPushButton("房间");
        m_scene2Btn = new QPushButton("教室");
        m_saveBtn = new QPushButton("保存");
        m_resetBtn = new QPushButton("重置");
        m_randomBtn = new QPushButton("随机");
        m_themeCheckBox = new QCheckBox("深色主题");
        m_confirmBtn = new QPushButton("确认搭配");

        // BGM控制
        m_bgmToggleBtn = new QPushButton("关闭BGM");
        m_volumeSlider = new QSlider(Qt::Horizontal);
        m_volumeLabel = new QLabel("音量: 50%");

        // 按钮样式
        QString buttonStyle = "QPushButton { background-color: rgba(255, 255, 255, 150); border: 1px solid rgba(255, 255, 255, 200); padding: 8px; } "
                             "QPushButton:hover { background-color: rgba(255, 255, 255, 200); }";
        m_scene1Btn->setStyleSheet(buttonStyle);
        m_scene2Btn->setStyleSheet(buttonStyle);
        m_saveBtn->setStyleSheet(buttonStyle);
        m_resetBtn->setStyleSheet(buttonStyle);
        m_randomBtn->setStyleSheet(buttonStyle);
        m_confirmBtn->setStyleSheet(buttonStyle);
        m_bgmToggleBtn->setStyleSheet(buttonStyle);

        // 滑块样式
        m_volumeSlider->setStyleSheet(
            "QSlider::groove:horizontal {"
            "    border: 1px solid rgba(255, 255, 255, 100);"
            "    height: 8px;"
            "    background: rgba(255, 255, 255, 50);"
            "    margin: 0px;"
            "    border-radius: 4px;"
            "}"
            "QSlider::handle:horizontal {"
            "    background: rgba(255, 255, 255, 200);"
            "    border: 1px solid rgba(255, 255, 255, 150);"
            "    width: 18px;"
            "    margin: -5px 0;"
            "    border-radius: 9px;"
            "}"
            "QSlider::handle:horizontal:hover {"
            "    background: rgba(255, 255, 255, 255);"
            "}"
        );
        m_volumeLabel->setStyleSheet("color: black; background: transparent;");

        // 添加右侧控件
        rightLayout->addWidget(new QLabel("背景音乐控制"));
        rightLayout->addWidget(m_bgmToggleBtn);
        rightLayout->addWidget(m_volumeLabel);
        rightLayout->addWidget(m_volumeSlider);
        rightLayout->addWidget(m_confirmBtn);
        rightLayout->addWidget(m_scene1Btn);
        rightLayout->addWidget(m_scene2Btn);
        rightLayout->addWidget(m_saveBtn);
        rightLayout->addWidget(m_resetBtn);
        rightLayout->addWidget(m_randomBtn);
        rightLayout->addWidget(m_themeCheckBox);
        rightLayout->addStretch();
        rightLayout->addWidget(m_loadingLabel);
        mainLayout->addWidget(rightWidget, 1);
}

// 事件绑定（仅连接信号与槽）
void MainWindow::initConnections()
{
        connect(m_upcloList, &QListWidget::itemClicked, this, &MainWindow::onUpListItemClicked);
      connect(m_downcloList, &QListWidget::itemClicked, this, &MainWindow::onDownListItemClicked);
      connect(m_shoesList, &QListWidget::itemClicked, this, &MainWindow::onShoesListItemClicked);
      connect(m_dressList, &QListWidget::itemClicked, this, &MainWindow::onDressListItemClicked);

      connect(m_scene1Btn, &QPushButton::clicked, this, &MainWindow::onScene1BtnClicked);
      connect(m_scene2Btn, &QPushButton::clicked, this, &MainWindow::onScene2BtnClicked);
      connect(m_saveBtn, &QPushButton::clicked, this, &MainWindow::onSaveBtnClicked);
      connect(m_resetBtn, &QPushButton::clicked, this, &MainWindow::onResetBtnClicked);
      connect(m_randomBtn, &QPushButton::clicked, this, &MainWindow::onRandomBtnClicked);
      connect(m_themeCheckBox, &QCheckBox::toggled, this, &MainWindow::onThemeCheckBoxToggled);
      connect(m_confirmBtn, &QPushButton::clicked, this, &MainWindow::onConfirmBtnClicked);

      // BGM连接
      connect(m_bgmToggleBtn, &QPushButton::clicked, this, &MainWindow::onBgmToggleBtnClicked);
      connect(m_volumeSlider, &QSlider::valueChanged, this, &MainWindow::onVolumeChanged);
      // 音量标签更新已经在onVolumeChanged中处理
}

// 保存功能（调用 QFileDialog 和 QPixmap 完成，逻辑简单无需拆分）
void MainWindow::onSaveBtnClicked()
{
    QPixmap pixmap = m_view->grab();
    QString fileName = QFileDialog::getSaveFileName(
        this, "保存搭配", "", "PNG图片 (*.png);;JPEG图片 (*.jpg *.jpeg);;所有文件 (*)"
    );
    if (fileName.isEmpty()) return;

    QFileInfo fileInfo(fileName);
    if (fileInfo.suffix().isEmpty()) fileName += ".png";

    if (!pixmap.save(fileName))
    {
        QMessageBox::warning(this, "保存失败", "无法保存图片文件，请检查路径权限");
    }
    else
    {
        QMessageBox::information(this, "保存成功", QString("图片已保存到:\n%1").arg(fileName));
    }
}

// 随机搭配（逻辑简单，直接实现）
void MainWindow::onRandomBtnClicked()
{
    clearCurrentClothes();
    QRandomGenerator* generator = QRandomGenerator::global();

    bool chooseDress = (generator->bounded(2) == 0) && (m_dressList->count() > 0);
    if (chooseDress)
    {
        int idx = generator->bounded(m_dressList->count());
        if (auto item = m_dressList->item(idx)) onDressListItemClicked(item);
    }
    else
    {
        if (m_upcloList->count() > 0)
        {
            int idx = generator->bounded(m_upcloList->count());
            if (auto item = m_upcloList->item(idx)) onUpListItemClicked(item);
        }

        if (m_downcloList->count() > 0)
        {
            int idx = generator->bounded(m_downcloList->count());
            if (auto item = m_downcloList->item(idx)) onDownListItemClicked(item);
        }
    }
    if (m_shoesList->count() > 0)
    {
        int idx = generator->bounded(m_shoesList->count());
        if (auto item = m_shoesList->item(idx)) onShoesListItemClicked(item);
    }
}

// 主题切换（委托给 ThemeManager）
void MainWindow::onThemeCheckBoxToggled(bool checked)
{
    if (checked)
    {
        m_themeManager->applyDarkTheme(
            m_view, m_upcloList, m_downcloList, m_shoesList, m_dressList,
            findChild<QWidget*>("rightWidget")
        );
    } else
    {
        m_themeManager->applyLightTheme(
            m_view, m_upcloList, m_downcloList, m_shoesList, m_dressList,
            findChild<QWidget*>("rightWidget")
        );
    }
}

// 套装检查（委托给 ComboChecker）
bool MainWindow::checkAndShowCombo()
{
    return m_comboChecker->checkAndShowCombo(
        m_upcloItem, m_downcloItem, m_dressItem, m_shoesItem,
        m_outfitCombos,
        [this](DragablePixmapItem *item) { return getClothesInfoByItem(item); },
        m_scene, m_comboItem, m_currentComboPath, m_showingCombo,
        static_cast<QWidget*>(this),
        m_characterItem,
        size()
    );
}

// 窗口大小变化（委托给 ScaleManager）
void MainWindow::resizeEvent(QResizeEvent *event)
{
    QMainWindow::resizeEvent(event);
    updateBackground();
    adjustCharacterAndClothesScale();
}

// 调整缩放（委托给 ScaleManager）
void MainWindow::adjustCharacterAndClothesScale()
{
    if (!m_characterItem) return;

    qreal scaleFactor = m_scaleManager->calculateScaleFactor(size());
    m_scaleManager->scaleCharacter(m_characterItem, m_characterPath, scaleFactor);
    m_scaleManager->centerCharacter(m_characterItem, m_view);
    m_scaleManager->scaleClothes(
        m_upcloItem, m_downcloItem, m_dressItem, m_shoesItem,
        [this](DragablePixmapItem *item) { return getClothesInfoByItem(item); },
        scaleFactor
    );
    if (m_showingCombo && m_comboItem && !m_currentComboPath.isEmpty())
    {
        m_scaleManager->scaleCombo(m_comboItem, m_currentComboPath, m_characterItem, scaleFactor);
    }
}

// 隐藏合成图（委托给 ComboChecker）
void MainWindow::hideCombo()
{
    m_comboChecker->hideCombo(m_scene, m_comboItem, m_currentComboPath, m_showingCombo);
    
    // 恢复显示原来的角色和衣服
    if (m_characterItem) m_characterItem->setVisible(true);
    if (m_upcloItem) m_upcloItem->setVisible(true);
    if (m_downcloItem) m_downcloItem->setVisible(true);
    if (m_dressItem) m_dressItem->setVisible(true);
    if (m_shoesItem) m_shoesItem->setVisible(true);
}

// 其他辅助函数（如 loadCharacter、loadClothes 等保持不变，仅做数据加载）
void MainWindow::loadCharacter()
{
    if (m_characterItem)
    {
        m_scene->removeItem(m_characterItem);
        delete m_characterItem;
        m_characterItem = nullptr;
    }

    QPixmap characterPixmap(m_characterPath);
    if (characterPixmap.isNull())
    {
        qWarning() << "Failed to load character image:" << m_characterPath;
        return;
    }

    m_characterItem = new QGraphicsPixmapItem;
    qreal scaleFactor = m_scaleManager->calculateScaleFactor(size());
    m_scaleManager->scaleCharacter(m_characterItem, m_characterPath, scaleFactor);
    m_scene->addItem(m_characterItem);
    m_scaleManager->centerCharacter(m_characterItem, m_view);
}
void MainWindow::loadClothes()
{
    auto addClothesToTab = [this](QListWidget* list, const QString& name, const QString& path) {
        QListWidgetItem* item = new QListWidgetItem;
        QPixmap pixmap(path);
        item->setIcon(pixmap.isNull() ? QIcon::fromTheme("image-x-generic") : QIcon(pixmap));
        item->setText(name);
        item->setSizeHint(QSize(100, 100));
        list->addItem(item);
    };

    for (const auto& info : m_clothesList) {
        if (info.category == "上衣") addClothesToTab(m_upcloList, info.name, info.path);
        else if (info.category == "下装") addClothesToTab(m_downcloList, info.name, info.path);
        else if (info.category == "鞋子") addClothesToTab(m_shoesList, info.name, info.path);
        else if (info.category == "连衣裙") addClothesToTab(m_dressList, info.name, info.path);
    }
}
void MainWindow::initBGM()
{
    m_audioManager->initBGM(":/bgm/materialPackage/bgm/happy.wav");
}

void MainWindow::checkAudioDevices()
{
    QAudioDeviceInfo defaultDevice = QAudioDeviceInfo::defaultOutputDevice();
    qDebug() << "默认音频设备:" << defaultDevice.deviceName();

    if (defaultDevice.isNull()) {
        QMessageBox::warning(this, "音频错误", "未检测到音频输出设备，请检查系统音频设置");
    }
}
void MainWindow::updateBackground()
{
    QString backgroundPath = (m_currentScene == 1)
        ? ":/scene/materialPackage/scene/roomscene.png"
        : ":/scene/materialPackage/scene/schoolscene.png";

    setStyleSheet(QString(
        "QMainWindow {"
        "   background-image: url(%1);"
        "   background-position: center;"
        "   background-repeat: no-repeat;"
        "   background-size: cover;"
        "}"
    ).arg(backgroundPath));
}

void MainWindow::clearCurrentClothes()
{
    // 只捕获this指针，因为只使用了成员变量m_scene
    auto removeItem = [this](DragablePixmapItem*& item) {
        if (item) {
            m_scene->removeItem(item);
            delete item;
            item = nullptr;
        }
    };

    removeItem(m_upcloItem);
    removeItem(m_downcloItem);
    removeItem(m_dressItem);
    removeItem(m_shoesItem);
}

void MainWindow::addClothesToScene(const ClothesInfo& info)
{
    hideCombo();

    DragablePixmapItem* currentItem = nullptr;
    auto createItem = [this, &info, &currentItem](DragablePixmapItem*& item) {
        if (item) {
            m_scene->removeItem(item);
            delete item;
        }
        item = new DragablePixmapItem(info.name);
        m_scene->addItem(item);
        connect(item, &DragablePixmapItem::positionChanged, this, &MainWindow::checkClothesCollision);
        currentItem = item;
    };

    if (info.category == "上衣") {
        createItem(m_upcloItem);
        if (m_dressItem) { removeItem(m_dressItem); }
    }
    else if (info.category == "下装") {
        createItem(m_downcloItem);
        if (m_dressItem) { removeItem(m_dressItem); }
    }
    else if (info.category == "连衣裙") {
        createItem(m_dressItem);
        removeItem(m_upcloItem);
        removeItem(m_downcloItem);
    }
    else if (info.category == "鞋子") {
        createItem(m_shoesItem);
    }

    if (currentItem) {
        QPixmap pixmap(info.path);
        if (!pixmap.isNull()) {
            qreal scaleFactor = m_scaleManager->calculateScaleFactor(size());
            QSize scaledSize = pixmap.size() * scaleFactor * 0.23;
            currentItem->setPixmap(pixmap.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
        }

        if (m_characterItem) {
            currentItem->setPos(m_characterItem->pos() + info.dragOffset);
        } else {
            currentItem->setPos(info.dragOffset);
        }
    }
}

ClothesInfo MainWindow::getClothesInfoByName(const QString& name)
{
    for (const auto& info : m_clothesList) {
        if (info.name == name) return info;
    }
    return ClothesInfo();
}

ClothesInfo MainWindow::getClothesInfoByItem(DragablePixmapItem* item)
{
    return item ? getClothesInfoByName(item->name()) : ClothesInfo();
}

void MainWindow::onUpListItemClicked(QListWidgetItem* item)
{
    if (!item) return;
    ClothesInfo info = getClothesInfoByName(item->text());
    if (info.name.isEmpty()) {
        QMessageBox::warning(this, "错误", "找不到选中的服饰信息");
        return;
    }
    addClothesToScene(info);
}

void MainWindow::onDownListItemClicked(QListWidgetItem* item)
{
    if (!item) return;
    ClothesInfo info = getClothesInfoByName(item->text());
    if (info.name.isEmpty()) {
        QMessageBox::warning(this, "错误", "找不到选中的服饰信息");
        return;
    }
    addClothesToScene(info);
}

void MainWindow::onShoesListItemClicked(QListWidgetItem* item)
{
    if (!item) return;
    ClothesInfo info = getClothesInfoByName(item->text());
    if (info.name.isEmpty()) {
        QMessageBox::warning(this, "错误", "找不到选中的服饰信息");
        return;
    }
    addClothesToScene(info);
}

void MainWindow::onDressListItemClicked(QListWidgetItem* item)
{
    if (!item) return;
    ClothesInfo info = getClothesInfoByName(item->text());
    if (info.name.isEmpty()) {
        QMessageBox::warning(this, "错误", "找不到选中的服饰信息");
        return;
    }
    addClothesToScene(info);
}

void MainWindow::onConfirmBtnClicked()
{
    bool hasCompleteOutfit = (m_upcloItem && m_downcloItem && m_shoesItem) ||
                             (m_dressItem && m_shoesItem);

    if (!hasCompleteOutfit) {
        QMessageBox::warning(this, "提示", "请选择完整搭配（上衣+下装+鞋子 或 连衣裙+鞋子）");
        return;
    }

    bool comboFound = checkAndShowCombo();
    QMessageBox::information(this, "提示", comboFound ?
        "已生成搭配效果！" : "搭配完成，但无特殊效果");
}

void MainWindow::onScene1BtnClicked()
{
    m_currentScene = 1;
    updateBackground();
}

void MainWindow::onScene2BtnClicked()
{
    m_currentScene = 2;
    updateBackground();
}

void MainWindow::onResetBtnClicked()
{
    hideCombo();
    clearCurrentClothes();
    if (!m_characterItem) loadCharacter();
}

void MainWindow::removeItem(DragablePixmapItem* item)
{
    if (item && m_scene) {
        m_scene->removeItem(item);
        delete item;
    }
}

void MainWindow::onBgmToggleBtnClicked()
{
    m_audioManager->toggleBgm();
    // 更新按钮文本
    if (m_bgmToggleBtn) {
        m_bgmToggleBtn->setText(m_audioManager->isPlaying() ? "关闭BGM" : "开启BGM");
    }
}

void MainWindow::onVolumeChanged(int volume)
{
    m_audioManager->setVolume(volume);
    if (m_volumeLabel) {
        m_volumeLabel->setText(QString("音量: %1%").arg(volume));
    }
}

void MainWindow::checkClothesCollision(DragablePixmapItem* clothesItem)
{
    if (!m_characterItem || !clothesItem || clothesItem->isWorn()) return;

    QRectF characterRect = m_characterItem->mapRectToScene(m_characterItem->boundingRect());
    QRectF clothesRect = clothesItem->mapRectToScene(clothesItem->boundingRect());
    QRectF intersection = characterRect.intersected(clothesRect);

    // 使用width() * height()计算面积，因为QRectF没有area()方法
    if (intersection.width() * intersection.height() > clothesRect.width() * clothesRect.height() * 0.3) {
        wearClothes(clothesItem);
    }
}

void MainWindow::wearClothes(DragablePixmapItem* clothesItem)
{
    if (!clothesItem || m_showingCombo) return;

    clothesItem->setWorn(true);
    clothesItem->setFlag(QGraphicsItem::ItemIsMovable, true);
    ClothesInfo info = getClothesInfoByItem(clothesItem);

    if (m_characterItem) {
        clothesItem->setPos(m_characterItem->pos() + info.wearOffset);
        clothesItem->setZValue(1);
    }
}

